package ar.edu.unq.wannaplay.utils.buttons;

import java.util.LinkedList;
import java.util.List;

import org.apache.wicket.ajax.markup.html.form.AjaxButton;

import ar.edu.unq.wannaplay.dtos.SkillDTO;
import ar.edu.unq.wannaplay.panels.AbstractEditModelObjectSkillsPanel;

public abstract class ActionOnListAjaxButton extends AjaxButton {

    private static final long serialVersionUID = 1L;

    private AbstractEditModelObjectSkillsPanel<?, ?> panel;

    public ActionOnListAjaxButton(final String id,
            final AbstractEditModelObjectSkillsPanel<?, ?> abstractEditModelObjectSkillsPanel) {
        super(id);
        panel = abstractEditModelObjectSkillsPanel;
    }

    @SuppressWarnings("unchecked")
    protected List<SkillDTO> getRealChoices() {
        List<SkillDTO> created = new LinkedList<SkillDTO>();
        created.addAll(panel.getChoicesList().getChoices());
        return created;
    }

    protected AbstractEditModelObjectSkillsPanel<?, ?> getPanel() {
        return panel;
    }

    public void setPanel(final AbstractEditModelObjectSkillsPanel<?, ?> panel) {
        this.panel = panel;
    }

}